/**
 * 变量名字的转换
 * const getUserApi_post = 'xxxx'
 * => const getUserAuth
 *
 * 处理逻辑
 * 1. 判断变量名字中有无 Api_post/Api_get 的后缀
 *    1.1 有就去除，并加上字符串Auth。
 *    1.2 没有就直接加上字符串Auth
 */
const END_WITH_REQUEST_TAG_REG = /(Api_get|Api_post)$/
// const isEndWithRequstTag = (apiName: string) => END_WITH_REQUEST_TAG_REG.test(apiName)

export const getAuthName = (apiName: string) =>
  END_WITH_REQUEST_TAG_REG.test(apiName)
    ? `${apiName.replace(END_WITH_REQUEST_TAG_REG, '')}Auth`
    : ''

export const getRequestName = (apiName: string) =>
  END_WITH_REQUEST_TAG_REG.test(apiName)
    ? `${apiName.replace(END_WITH_REQUEST_TAG_REG, '')}Api`
    : ''
